package com.git_taoxian.test5;

import java.util.HashSet;

public class Test {
    public static void main(String[] args) {
//        定义一个HashSet集合并添加多个Student类型的对象到集合中
        HashSet<Student> hashSet = new HashSet<>();
        hashSet.add(new Student("张三","男",20));//调用全参构造方法
        hashSet.add(new Student("李四","女",21));
        hashSet.add(new Student("张三","男",20));
//        增强for循环打印
        for (Student student : hashSet) {
            System.out.println(student);//重写toString方法
        }
    }
}
